<?php

namespace App\Http\Controllers\Index;
use Illuminate\Http\Request;
use Style, DB;

class TestController extends CommonController{
    /**
     * 去除企业表相同的手机号码
     * @param Request $request
     */
    public function companyMobileMerge(Request $request){
        $companyUser = DB::select("select uid from cms_company_users where mobile!='' group by mobile having count(mobile) >1");
        //去除重复值
        if(count($companyUser) > 0){
            foreach($companyUser as $v){
                $mobileArr[] = $v->uid;
            }
            $uid = implode(',', $mobileArr);
            DB::update("update cms_company_users set mobile =NULL where uid in (" . $uid . ")");
        }
        //更新null
        if(count($companyUser) <= 0){
            DB::select("update cms_company_users set mobile =NULL where mobile=''");
            exit('完成');
        }else{
            //跳转页面
            return redirect('company/company_mobile_merge');
        }
    }


    public function test(Request $request){
        dd(33);

    }




}